Auto-Increment Fields

Description

If there are NO records in the table, the initial value in the field (the so called 'seed' value) can be set by specifying a " default value " field rule and setting the " set value at start of data entry ". If there are existing records in the table, then when the user starts to enter a new record, Alpha Anywhere shows a "likely" value for the auto-increment field. This "likely" value is the previous high value in the field plus one. The user if free to change this "likely" value as long as he enters a number that is higher than any existing value. If the user breaks the sequence and enters a higher value than the likely value, then the sequence for all subsequent records starts with the value entered by the user. The user can never change the value in a previously saved record.

The user can never override the "likely" value with a number that is lower than the previously recorded high value for the field. The reason that the value that displays when the user starts entering a new record is called the "likely" value is that it is not really known until the record is saved what the value will be. For example, say a table has 4 records and two users begin entering a new record. User 1 will see the value of "5" in his new record. User 1 has not yet saved his record. User 2 now starts a new record. he also sees a value of "5". If user 2 saves before user 1 then his record will get the value of "5". If user 1 then saves, the "5" in the record will change to "6".

Creating an Auto-Increment Field

  1. Display the Tables/Sets tab of the Control Panel.

  2. Select the table that will contain the auto-increment field.

  3. Select Design > Field Rules.

  4. Select the field that will be auto-numbered from the drop-down list at top left.

  5. On the Field Types tab under Extended field types select Auto increment.

  6. Display the Data Entry tab.

  7. In the Required section select "Always required".

  8. Check Auto advance after field filled.

  9. For Default mode select "Simple default expression".

  10. For Default value set the initial value of the series. If this is a character field, put quotes around the value (e.g. 00001 for a numeric field and "00001" for a character field).

  11. Put .T. into the Skip field.

  12. Click Save and exit from the Field Rules editor.

See Also